// Copyright 2013 Google Inc. All Rights Reserved.

#include <errno.h>

#include <irt_syscalls.h>
#include <nacl_fcntl.h>

#include <unistd.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>

struct nacl_abi_dirent;
struct dirent;

int getdents(int desc, struct nacl_abi_dirent *buf, size_t count) {
  ENOSYS_IF_NULL(__nacl_irt_getdents)

  size_t nread;
  int result = __nacl_irt_getdents(desc, (struct dirent*) buf, count, &nread);
  if (result) {
    errno = __nacl_abi_errno_to_errno(result);
    return -1;
  }
  return nread;
}
